//package com.bicon.bdata_service_search.es;
//
//import org.elasticsearch.action.search.SearchRequestBuilder;
//import org.elasticsearch.client.transport.TransportClient;
//import org.elasticsearch.common.settings.Settings;
//import org.elasticsearch.common.transport.InetSocketTransportAddress;
//import org.elasticsearch.common.transport.TransportAddress;
//import org.elasticsearch.transport.client.PreBuiltTransportClient;
//
//import java.net.InetAddress;
//
///**
// * 描述:
// * get connection
// *
// * @author 086
// * @create 2018-08-21 11:43
// */
//public class GetConnection {
//    //    private static Logger logger = LoggerFactory.getLogger(GetConnection.getClass());
//    public final static String HOST = "192.168.10.181";
//    // http请求的端口是9200，客户端是9300
//    public final static int PORT = 9300;
//
//    /**
//     * getConnection:(获取es连接).
//     *
//     * @return
//     * @throws Exception
//     * @author 086 2018-08-21 11:43
//     */
//    @SuppressWarnings({"resource", "unchecked"})
//    public static TransportClient getConnection() throws Exception {
//        // 设置集群名称
//        Settings settings = Settings.builder().put("cluster.name", "my-es").build();
//        // 创建client
//        TransportClient client = new PreBuiltTransportClient(settings).addTransportAddresses(new InetSocketTransportAddress(InetAddress.getByName(HOST), PORT));
//
//        client.close();
//        return client;
//    }
//
//    public static void main(String[] args) throws Exception {
//        TransportClient client = getConnection();
////        logger.info("client == "+client.toString());
////        System.out.println("client==" + client.toString());
////        SearchRequestBuilder searchRequestBuilder = client.prepareSearch("question_and_answer_index").setTypes("questionAndAnswer").setFrom(0);
////        System.out.print(searchRequestBuilder);
//        System.out.print("this is a es search");
//
//    }
//}